package zone.czh.woi.woim.configurator;
import lombok.Data;
import lombok.experimental.Accessors;
import zone.czh.woi.woim.base.channel.adapter.ProtobufAdapter;
import zone.czh.woi.woim.base.channel.adapter.ProtocolAdapter;
import zone.czh.woi.woim.base.channel.adapter.WebSocketAdapter;
import zone.czh.woi.woim.base.channel.codec.PacketHandler;
import zone.czh.woi.woim.server.channel.protocol.detector.ProtocolDetector;
import zone.czh.woi.woim.base.channel.protocol.selector.ProtocolSelector;
import zone.czh.woi.woim.channel.auth.verifier.DefaultVerifier;
import zone.czh.woi.woim.channel.auth.verifier.WOIMVerifier;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*@ClassName: DefaultWOIMConfigurator
*@Description: None
*@author woi
*/
@Data
@Accessors(chain = true)
public class DefaultWOIMConfigurator implements WOIMConfigurator{
    Map<String,ProtocolAdapter> adapters ;

    ProtocolAdapter protobufAdapter ;

    ProtocolAdapter webSocketAdapter ;

    ProtocolSelector protocolSelector;

    ProtocolDetector protocolDetector;

    public DefaultWOIMConfigurator(){
        adapters = new HashMap<>();
        protobufAdapter = new ProtobufAdapter();
        webSocketAdapter = new WebSocketAdapter();
        adapters.put(protobufAdapter.getProtocolName(),protobufAdapter);
        adapters.put(webSocketAdapter.getProtocolName(),webSocketAdapter);
    }

    @Override
    public WOIMVerifier getChannelVerifier() {
        return new DefaultVerifier();
    }

    @Override
    public List<PacketHandler> getCustomHandler() {
        return null;
    }

    @Override
    public ProtocolDetector getProtocolDetector() {
        return protocolDetector;
    }

    @Override
    public Map<String,ProtocolAdapter> getProtocolAdapters() {
        return adapters;
    }

    @Override
    public ProtocolSelector getProtocolSelector() {
        return protocolSelector;
    }

}
